﻿<UserControl
	xmlns="http://schemas.microsoft.com/client/2007"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:this="clr-namespace:OnlineBattlemat"
	x:Class="OnlineBattlemat.Page" MinWidth="800" MinHeight="600">
	<UserControl.Resources>
		<DataTemplate x:Name="ListItemTemplate">
			<StackPanel Orientation="Horizontal" MouseLeftButtonDown="TokenPickerButton_MouseLeftButtonDown">
				<Image x:Name="ItemImage" Source="{Binding Image}" Width="80" Height="80" Stretch="Uniform" />
				<TextBlock Text="{Binding Name}" />
			</StackPanel>
		</DataTemplate>
	</UserControl.Resources>

	<Grid>
		<Grid.Background>
			<LinearGradientBrush StartPoint="0,0" EndPoint=".25,.25">
				<GradientStop Color="Sienna" Offset="0"/>
				<GradientStop Color="Chocolate" Offset="1"/>
			</LinearGradientBrush>
		</Grid.Background>
		<Grid.RowDefinitions>
			<RowDefinition Height="45" />
			<RowDefinition />
		</Grid.RowDefinitions>

		<Border BorderBrush="DarkGoldenrod" BorderThickness="0,0,0,1" Grid.Column="0" Grid.Row="0">
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="2*" />
					<ColumnDefinition Width="6*" />
					<ColumnDefinition Width="2*" />
				</Grid.ColumnDefinitions>

				<TextBlock x:Name="x_LogoTextBlock" Text="Online Battlemat" FontSize="20" FontWeight="Bold" Grid.Column="0" VerticalAlignment="Center" Margin="10,0,0,0" />

				<TextBlock x:Name="x_SessionNameTextBlock" Text="" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" />

				<TextBlock x:Name="x_CurrentUserTextBlock" Text="Welcome" Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0" />
			</Grid>
		</Border>

		<Grid Grid.Column="1" Grid.Row="1">
			<ScrollViewer x:Name="x_MainScrollViewer" Height="555" Width="800" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
				<Grid>
					<Canvas x:Name="x_MainCanvas" Height="4000" Width="4000">
						<Canvas.RenderTransform>
							<ScaleTransform x:Name="x_CanvasZoomTransform" />
						</Canvas.RenderTransform>
						<Canvas.Background>
							<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
								<GradientStop Color="Tan" Offset="0"/>
								<GradientStop Color="Khaki" Offset=".4"/>
								<GradientStop Color="Moccasin" Offset="1"/>
							</LinearGradientBrush>
						</Canvas.Background>

						<InkPresenter HorizontalAlignment="Left" VerticalAlignment="Top"
							x:Name="x_InkPresenterElement" Width="4000" Height="4000"
							Background="Transparent"  
							MouseLeftButtonDown="x_InkPresenterElement_MouseDown" 
							MouseMove="x_InkPresenterElement_MouseMove"
							MouseLeftButtonUp="x_InkPresenterElement_MouseUp"
                            KeyDown="x_InkPresenterElement_KeyDown">
                            <InkPresenter.RenderTransform>
								<ScaleTransform x:Name="x_InkZoomTransform" />
							</InkPresenter.RenderTransform>
						</InkPresenter>

					</Canvas>


				</Grid>
			</ScrollViewer>
			<StackPanel x:Name="x_TopButtonStackPanel" Orientation="Horizontal" VerticalAlignment="Top" Canvas.ZIndex="10" Height="45">
				<Button ToolTipService.ToolTip="The tool you're currently using" Margin="3" IsEnabled="False">
					<Button.Content>
						<Image x:Name="x_SelectedToolImage" Source="images/select2.png" Width="30" Height="30" />
					</Button.Content>
				</Button>

				<Button x:Name="x_PointerButton" ToolTipService.ToolTip="Dragging and selecting" Margin="3" Click="x_PointerButton_Click">
					<Button.Content>
						<Image Source="images/select2.png" Width="30" Height="30" />
					</Button.Content>
				</Button>

				<Button x:Name="x_ColorButton" Margin="3" ToolTipService.ToolTip="Pen for drawing on the battlemat" Click="x_ColorButton_Click">
					<Button.Content>
						<StackPanel>
							<Image x:Name="x_ColorButtonImage" Source="images/blackPen_button.png" Width="30" Height="30" />
							<Popup x:Name="x_ColorPopup" IsOpen="False">
								<Border Background="White" BorderBrush="Black" BorderThickness="1">
									<StackPanel>
										<Button Margin="3" x:Name="x_ColorBlackButton" Click="ColorPickerButton_Click">
											<Button.Content>
												<Border Background="Black" BorderBrush="Black" BorderThickness="2" Width="30" Height="30"/>
											</Button.Content>
										</Button>
										<Button Margin="3" x:Name="x_ColorBlueButton" Click="ColorPickerButton_Click">
											<Button.Content>
												<Border Background="Blue" BorderBrush="Black" BorderThickness="2" Width="30" Height="30"/>
											</Button.Content>
										</Button>
										<Button Margin="3" x:Name="x_ColorGreenButton" Click="ColorPickerButton_Click">
											<Button.Content>
												<Border Background="Green" BorderBrush="Black" BorderThickness="2" Width="30" Height="30"/>
											</Button.Content>
										</Button>
										<Button Margin="3" x:Name="x_ColorRedButton" Click="ColorPickerButton_Click">
											<Button.Content>
												<Border Background="Red" BorderBrush="Black" BorderThickness="2" Width="30" Height="30"/>
											</Button.Content>
										</Button>
									</StackPanel>
								</Border>
							</Popup>
						</StackPanel>
					</Button.Content>
				</Button>

				<Button x:Name="x_EraserButton" ToolTipService.ToolTip="Eraser for removing things from the battlemat" Margin="3" Click="x_EraserButton_Click">
					<Button.Content>
						<Image Source="images/eraser.png" Width="30" Height="30" />
					</Button.Content>
				</Button>

				<Button x:Name="x_TemplatesButton" Margin="3" ToolTipService.ToolTip="Templates for measuring area effects" Click="x_TemplatesButton_Click">
					<Button.Content>
						<StackPanel>
							<Image Source="images/templates_button.png" Width="30" Height="30" />

							<Popup x:Name="x_TemplatesPopup" IsOpen="False">
								<Border Background="White" BorderBrush="Black" BorderThickness="1">
									<StackPanel>
										<Button x:Name="x_10ftRadiusTemplateButton" Content="10-ft. Radius" Margin="3" Click="TemplatePickerButton_Click" />
										<Button x:Name="x_20ftRadiusTemplateButton" Content="20-ft. Radius" Margin="3" Click="TemplatePickerButton_Click" />
									</StackPanel>
								</Border>
							</Popup>
						</StackPanel>
					</Button.Content>
				</Button>

				<Button x:Name="x_TokensButton" Margin="3" ToolTipService.ToolTip="Place tokens you've uploaded" Click="x_TokensButton_Click">
					<Button.Content>
						<StackPanel>
							<Image Source="images/tokens_button.png" Width="30" Height="30" />

							<Popup x:Name="x_TokensPopup" IsOpen="False">
								<Border Background="White" BorderBrush="Black" BorderThickness="1">
									<ListBox x:Name="x_TokenListBox" ItemTemplate="{StaticResource ListItemTemplate}" />
								</Border>
							</Popup>
						</StackPanel>
					</Button.Content>
				</Button>

				<Button x:Name="x_UploadTokenButton" Margin="3" ToolTipService.ToolTip="Upload a new token" Click="x_UploadTokenButton_Click">
					<Button.Content>
						<Image Source="images/upload_button.png" Width="30" Height="30" />
					</Button.Content>
				</Button>
			</StackPanel>

			<StackPanel x:Name="x_LeftSideButtonsStackPanel" Canvas.ZIndex="10" HorizontalAlignment="Left" Margin="0,45,0,0">
				<Button x:Name="x_ZoomInButton" Margin="3" Content="+" ToolTipService.ToolTip="Zoom In" Width="20" Click="x_ZoomInButton_Click" HorizontalAlignment="Left"/>
				<Button x:Name="x_ZoomCenterButton" Margin="10,3,3,3" Content="*" ToolTipService.ToolTip="Zoom to Center" Width="20" Click="x_ZoomCenterButton_Click" HorizontalAlignment="Left"/>
				<Button x:Name="x_FullscreenButton" Margin="10,3,3,3" Content="O" ToolTipService.ToolTip="Fullscreen" Width="20" Click="x_FullscreenButton_Click" HorizontalAlignment="Left"/>
				<Button x:Name="x_ZoomOutButton" Margin="3" Content="-" ToolTipService.ToolTip="Zoom Out" Width="20" Click="x_ZoomOutButton_Click" HorizontalAlignment="Left" />
			</StackPanel>

			<this:PlayerPanel VerticalAlignment="Top" HorizontalAlignment="Right"/>
		</Grid>

		<!--Gray-out background -->
		<Rectangle x:Name="x_DropClothRectangle" Fill="LightSlateGray" Opacity=".7" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1" Visibility="Collapsed" />

		<!-- Dialogs -->
		<this:JoinSessionControl x:Name="x_JoinSessionDialog" Grid.Row="1" Visibility="Collapsed"/>
		<this:UploadImageControl x:Name="x_UploadImageDialog" Grid.Row="1" Visibility="Collapsed"/>
	</Grid>
</UserControl>
